<template>
  <div class="wholesale-list block">
    <div class="header">
      <h2 class="title">发票信息</h2>
      <el-form ref="queryForm" :inline="true" label-position="right" :model="tableQuery">
        <el-form-item label="开票日期">
          <el-date-picker
            v-model="invoiceDate"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="daterange"
            :default-time="['00:00:00', '23:59:59']"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="销售日期">
          <el-date-picker
            v-model="saleDate"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="daterange"
            range-separator="至"
            :default-time="['00:00:00', '23:59:59']"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="经销商名称">
          <el-select
            v-model="tableQuery.companyId"
            filterable
            maxlength="30"
            remote
            clearable
            placeholder="请输入关键词"
            :remote-method="companyRemoteMethod"
            :loading="loading"
          >
            <el-option
              v-for="item in companyOptions"
              :key="item.companyId"
              :label="item.companyName"
              :value="item.companyId"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="报台单号">
          <el-input
            maxlength="30"
            v-model.trim="tableQuery.newspaperCode"
            type="text"
            placeholder="请输入"
          />
        </el-form-item>
        <el-form-item label="医院">
          <el-select
            v-model="tableQuery.saleTargetCode"
            filterable
            maxlength="30"
            remote
            clearable
            placeholder="请输入关键词"
            :remote-method="saleTargetRemoteMethod"
            :loading="loading"
          >
            <el-option
              v-for="(item,num) in saleTargetOptions"
              :key="num"
              :label="item.saleTargetName"
              :value="item.saleTargetCode"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="发票号">
          <el-input
            maxlength="30"
            v-model.trim="tableQuery.invoiceNum"
            type="text"
            placeholder="请输入"
          />
        </el-form-item>
        <el-form-item label="状态" v-show="collapse">
          <el-select v-model="tableQuery.orderStatus" clearable placeholder="请选择">
            <el-option label="生成" value="21"></el-option>
            <el-option label="冲红" value="22"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="上传时间" v-show="collapse">
          <el-date-picker
            v-model="uploadTime"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="daterange"
            :default-time="['00:00:00', '23:59:59']"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>

        <el-form-item class="form-button">
          <el-button type="text" @click="collapse=!collapse" v-if="height_collapse">
            <span v-if="collapse">
              收起详细查询
              <i class="el-icon-arrow-up" />
            </span>
            <span v-else>
              展开详细查询
              <i class="el-icon-arrow-down" />
            </span>
          </el-button>
          <el-button type="primary" @click="queryFormQuery">查询</el-button>
          <el-button @click="queryFormReset">重置</el-button>
        </el-form-item>
        <div class="clear"></div>
      </el-form>
    </div>
    <section class="el-container container-box is-vertical">
      <div class="operate">
        <el-button type="primary" size="mini" @click="exportDialog">批量下载</el-button>
      </div>
      <el-editable
        row-key="orderId"
        :data="payload.content"
        height="400"
        stripe
        ref="tableRef"
        v-loading="tableLoading"
        :columns="listColumns"
        :payload="payload"
        :needPagination="true"
        @reload="reloadProductData"
      >
        <template slot="default-operation" slot-scope="scope">
          <el-button type="text" @click="download(scope)">下载</el-button>
        </template>
      </el-editable>
      <el-dialog
        title="批量下载日期选择"
        custom-class="dialog-custom"
        :visible.sync="delDialogVisible"
        width="40%"
      >
        <el-form
          ref="dialogQueryForm"
          :rules="rules"
          :inline="true"
          label-position="right"
          :model="dialogTableQuery"
          label-width="150"
        >
          <el-form-item label="销售日期起止" required>
            <el-col :span="10">
              <el-form-item prop="saleDateStart">
                <el-date-picker
                  type="date"
                  placeholder="选择开始日期"
                  value-format="yyyy-MM-dd "
                  v-model="dialogTableQuery.saleDateStart"
                  style="width: 100%;"
                  :picker-options="pickerOptions1"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col class="line" :span="1">-</el-col>
            <el-col :span="10">
              <el-form-item prop="saleDateEnd">
                <el-date-picker
                  placeholder="选择结束日期"
                  value-format="yyyy-MM-dd "
                  v-model="dialogTableQuery.saleDateEnd"
                  style="width: 100%;"
                  :picker-options="pickerOptions2"
                ></el-date-picker>
              </el-form-item>
            </el-col>
          </el-form-item>
        </el-form>
        <p style="color:red;">最多可选择31天的数据</p>
        <div class="delBtn">
          <el-button @click="delDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="rushRedOk">确认</el-button>
        </div>
      </el-dialog>
    </section>
  </div>
</template>

<script src="./index.js"></script>

<style lang="less" src="./index.less" scoped></style>
